<template>
<view class="cp_container">
	<u-button
		class="u-button"
		@click='()=>{
			show[1].show1 = true;
			show[1].show2 = true;
		}'>
		整体推进情况
	</u-button>
	<u-input
		v-show="show[1].show1"
		v-model="dataInfo.inputa" 
		maxlength="100000"
		type="textarea" 
		:border="true"/>
	<u-button
		class="u-button"
		@click='()=>{
			show[2].show1 = true;
			show[2].show2 = true;
		}'>
		分批次完成情况
	</u-button>
	<u-input
		v-show="show[2].show1"
		v-model="dataInfo.inputb" 
		type="textarea"
		maxlength="100000"
		:border="true"/>
	<u-button
		class="u-button"
		@click='()=>{
			show[3].show1 = true;
			show[3].show2 = true;
		}'>
		分责任单位完成情况
	</u-button>
	<u-input
		v-show="show[3].show1"
		v-model="dataInfo.inputc" 
		type="textarea" 
		maxlength="100000"
		:border="true"/>
	<u-button 
		class="u-button"
		@click="$emit('onClose')">项目明细</u-button>
	<u-button
		class="u-button"
		@click="onSave"
		type="primary">
		保存
	</u-button>
	<u-modal
		v-model="show[1].show2" 
		title="整体推进情况">
		<scroll-view 
			class="modal2_container"
			:scroll-y="true">
			{{dataInfo.inputa || ''}}
		</scroll-view>
	</u-modal>
	<u-modal
		v-model="show[2].show2" 
		title="分批次完成情况">
		<scroll-view 
			class="modal2_container"
			:scroll-y="true">
			{{dataInfo.inputb || ''}}
		</scroll-view>
	</u-modal>
	<u-modal
		v-model="show[3].show2" 
		title="分责任单位完成情况">
		<scroll-view 
			class="modal2_container"
			:scroll-y="true">
			{{dataInfo.inputc || ''}}
		</scroll-view>
	</u-modal>
	<u-toast ref="uToast" />
</view>
</template>

<script>
//新建项目页面
import {getByLevel,saveOverall} from "@/common/Api";
export default {
	components: {},
	props:{
		level:{
			type:String,
			default:'',
		},
	},
	data() {
		return {
			value:'',
			show:{  //控制输入框以及对话框的显示
				1:{
					show1:false,
					show2:false,
				},
				2:{
					show1:false,
					show2:false,
				},
				3:{
					show1:false,
					show2:false,
				},
			},
			dataInfo:{
				inputa:'',
				inputb:'',
				inputc:'',
			},
		}
	},
	created(){
		this.getData();
	},
	methods: {
		getData(){  //获取数据
			getByLevel({
				level:this.level,
			}).then(res=>{
				this.dataInfo = res.data.data;
			});
		},
		onSave(){  //保存
			saveOverall({
				...this.dataInfo,
				level:this.level,
			}).then(res=>{
				this.$refs.uToast.show({
					title: '保存成功',
					type: 'success',
				});
				setTimeout(()=>{
					this.$emit('onClose');
				},100);
			});
		},
	}
}
</script>

<style lang="scss" scoped>
.cp_container {
	display: grid;
	grid-gap: 15px;
	text-align: left;
	width: 100%;
	padding: 20px 15px;
	box-sizing: border-box;
	/deep/.u-input{
		width: 100%;
	}
	/deep/.u-button{
		width: 100%;
	}
}
.modal2_container{
	max-height: 60vh;
	box-sizing: border-box;
	padding: 15px;
	box-sizing: border-box;
	display: grid;
	grid-gap: 5px;
}
</style>
